<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>学校教务管理系统</title>
    <script type="text/javascript" th:src="@{/static/js/jquery-3.1.1.js}"></script>
    <script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/marked.js}"></script>
    <link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/index.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/github-markdown.css}"/>

</head>
<body style="background: url('https://img.zcool.cn/community/017fcb554385660000019ae9065097.jpg@2o.jpg');background-size: cover">
<div id="totop">
    <i class="layui-icon">&#xe619;</i>
</div>

<blockquote style="margin: 15px;background-color:#FFFFFF;" class="layui-elem-quote"><i class="layui-icon">&#xe67a;</i>
    新版学校教务管理系统将于2025年3月11日启用。
</blockquote>

<div class="layui-row">
 <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">

1 </div>
    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">

        <div class="layui-card">
            <div class="layui-card-header">用户登录</div>
            <div class="layui-card-body">
                <form class="layui-form" th:action="@{/admin/login}">
                    <div class="layui-form-item">
                        <input class="layui-input" name="username" placeholder="学号 / 工号 / 用户名" lay-verify="required" type="text" autocomplete="off">
                    </div>
                    <div class="layui-form-item">
                        <input class="layui-input" name="password" placeholder="密码" lay-verify="required" type="password" autocomplete="off">
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs9">
                            <div class="layui-form-item form_code">
                                <input class="layui-input" name="code" placeholder="验证码" lay-verify="required" type="text" autocomplete="off">

                            </div>
                        </div>
                        <div class="layui-col-xs3">
                            <div class="code"><img th:src="@{/getCaptcha}" width="116" height="36" th:id="randImage"></div>
                        </div>
                    </div>



                    <div class="layui-form-item" style="display: none;">
                        <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住帐号?">
                    </div>
                    <button class="layui-btn layui-btn-fluid login_btn" lay-submit lay-filter="login">登录</button>
                </form>
            </div>
        </div>





    </div>



</div>


</body>
<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
</html>
<script>
    layui.use(['form','layer'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : parent.layer;
        $ = layui.jquery;

        //登录按钮事件
        form.on("submit(login)", function(data){
            var loadIndex = layer.load(2, {shade: [0.3, '#333']});
            if($('form').find('input[type="checkbox"]')[0].checked){
                data.field.rememberMe = true;
            }else{
                data.field.rememberMe = false;
            }
            $.post(data.form.action, data.field, function(res) {
                layer.close(loadIndex);
                if(res.success){
                    location.href="/"+res.url;
                }else{
                    layer.msg(res.message);
                    $("#randImage").click();
                }
            });
            return false;
        });

        $("#randImage").click(function () {
            this.src = "/getCaptcha?t=" + Math.random();
        });
    });

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer;


        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });

    });
    /**
     * 时间显示
     */
    setInterval(function () {
            $('#toptime'
            ).text('今天是' + getDate());
        },
        1000
    )

    function getDate() {
        var myDate = new Date();
        var year = myDate.getFullYear();
        var month = myDate.getMonth() + 1;
        var date = myDate.getDate();
        var h = myDate.getHours();
        var m = myDate.getMinutes();
        var s = myDate.getSeconds();
        var now = year + '年' + conver(month) + "月" + conver(date) + "日 " + conver(h) + ':' + conver(m) + ":" + conver(s);
        return now;
    }

    function conver(s) {
        return s < 10 ? '0' + s : s;
    }

    layui.use(['flow', 'element'], function () {
        var $ = layui.jquery; //不用额外加载jQuery，flow模块本身是有依赖jQuery的，直接用即可。
        var flow = layui.flow;
        flow.load({
            elem: '#newslist' //指定列表容器
            , isAuto: false
            , done: function (page, next) { //到达临界点（默认滚动触发），触发下一页
                var lis = [];
                //以jQuery的Ajax请求为例，请求下一页数据（注意：page是从2开始返回）
                $.get('/newslist?page=' + page, function (res) {
                    //假设你的列表返回在data集合中
                    layui.each(res.data, function (index, item) {
                        lis.push('<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">&#xe63f;</i><div class="layui-timeline-content layui-text"><h1 style="color: #ca006f;" class="layui-timeline-title">'+ item.ntitle +'</h1><h4>'+ fDate(item.ntime) + ' - '+item.nauthor +'</h4><p>'+ marked(item.ncontent) +'</p></div></li>');

                    });
                    next(lis.join(''), page < res.pages);
                });
            }
        });
    });


    /**
     * 转换时间格式
     */
    function fDate(date) {
        var d = new Date(date);
        var month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
        var day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
        var hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
        var min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
        var sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
        var times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec;
        return times
    }

    /**
     * 返回顶部
     */
    $("#totop").on('click', function () {
        document.body.scrollTop = 0;
        document.documentElement.scrollTop = 0;
    });

    /**
     * 加载作息时间表
     */
    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#scheduleTable'
            , url: '/schedulelist'
            , size: 'sm'
            , cols: [
                [
                    {field: 'schid', title: '序号', width: 50}
                    , {field: 'timeinterval', title: '时段', width: 60}
                    , {field: 'schname', title: '节序', width: 80}
                    , {field: 'summer', title: '夏季时间'}
                    , {field: 'winter', title: '冬季时间'}
                ]
            ]
        });
    });
</script>
